<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jsunit/app/jsUnitCore.js"></script>
<script type="text/javascript" src="test1.js"></script>
<script type="text/javascript">

var count = 0;

var arg1;
var arg2;

//此函数会在页面加载后首先执行，并且只执行一次，类似于JUnit4中的@BeforeClass注解
function setUpPage()
{
	arg1 = 3;
	arg2 = 6;

	//此行代码必须放置在setUpPage的最后，在完成资源加载后告诉JsUnit该函数已执行完毕
	setUpPageStatus = "complete"; 
}


function setUp() //类比于JUnit中的setUp
{
	//count++;
	
	document.getElementById("value1").value = 6;
	document.getElementById("value2").value = 7;

}

function tearDown() //类比于JUnit中的tearDown
{
	document.getElementById("value1").value = "";
	document.getElementById("value2").value = "";
}


// 测试函数
function testAdd()
{
	var result = add(4, 2);
	assertEquals(6, result);
	warn("result " , result);
}

function testMinus()
{
	var result = minus(4, 2);
	assertEquals(2, result);
}

function testMultiply()
{
	var result = multiply(4, 2);
	assertEquals(8, result);
}

function testDivide()
{
	var result = divide(4, 2);
	assertEquals(2, result);
}


function testSetUpPage()
{
	var result = arg1 + arg2;
	assertEquals(9, result);
}



//向JsUnit框架显式暴露测试函数名
//function exposeTestFunctionNames()
//{
//	var tests = new Array();

//	tests[0] = "testAdd";
//	tests[1] = "testMinus";
//	tests[2] = "testMultiply";
//	tests[3] = "testDivide";

//	return tests;
//}


function addNumbers()
{
	var v1 = document.getElementById("value1").value;
	var v2 = document.getElementById("value2").value;

	var result = addTwoNumbers(v1, v2);
	
	//document.getElementById("result").value = result;

	return result;
}

function testAddNumbers()
{
	var result = addNumbers();

	assertEquals(13, result);
}

</script>



</HEAD>

<BODY>

<form>
<input type="text" id="value1"><br>
<input type="text" id="value2"><br>
<input type="text" id="result"><br>
<input type="button" value="Add" onclick="addNumbers()">
</form>
</BODY>
</HTML>
